<template>
	<view class="container">

		<view class="pho" v-if="code">
			<image :src="code"  mode="" :show-menu-by-longpress="true"  @click="previewImage"></image>
		</view>
		<view class="pho" v-if="!code">
			网络不佳，请刷新
		</view>
<!-- 		<view class="text">
			欢迎大家扫码进群
		</view> -->
	</view>
</template>

<script>
	import {
		wechatCode
	} from '../../request/api.js'
	export default {
		data() {
			return {
				code: ''
			}
		},
		onLoad() {
			wechatCode().then(res => {
				this.code = res.data.data[0].qrCode
				console.log(res.data.data[0].qrCode);
			})
		},
		methods: {
			previewImage(e) {
				console.log('e', e);
				uni.previewImage({
					// 需要预览的图片链接列表
					urls: [this.code],
					// 为当前显示图片的链接/索引值
					current: this.code,
					// 图片指示器样式	
					indicator: 'default',
					// 是否可循环预览
					loop: false,
					// 长按图片显示操作菜单，如不填默认为保存相册
					// longPressActions:{
					// 	itemList:[this.l('发送给朋友'),this.l]
					// },
					success: res => {
						console.log('res', res);
					},
					fail: err => {
						onsole.log('err', err);
					}
				});
			}

		}
	}
</script>

<style lang="less" scoped>
	.container {
		width: 100vw;
		height: 100vh;
		background-color: rgb(242, 242, 242);
		text-align: center;
		padding-top: 10vh;

		.pho {
			padding-bottom: 2vh;
			width: 80%;
			height: 60%;
			margin-left: 10%;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.text {
			font-size: 40rpx;
		}
	}
</style>
